package com.gf.framework.translatordemo.controller;

import com.gf.framework.common.result.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @author gaofei
 * @Description
 * @create 2022/5/27 14:54
 */
@Api(tags = "时间类型传输测试")
@RestController
@RequestMapping("timetest")
@Slf4j
public class TimeController {
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class TimeTestVo {
        private LocalDate localDate;
        private LocalDateTime localDateTime;
    }

    @PostMapping("post1")
    public Boolean post1(@RequestBody TimeTestVo timeTestVo) {
        log.info(timeTestVo.toString());
        return true;
    }

    @GetMapping("get")
    public TimeTestVo get() {
        return new TimeTestVo(LocalDate.now(), LocalDateTime.now());
    }

    @GetMapping("get2")
    public R<TimeTestVo> get2() {
        return R.success(new TimeTestVo(LocalDate.now(), LocalDateTime.now()));
    }

    @GetMapping("get3")
    public Boolean get3() {
        int a = 10 / 0;
        return true;
    }
}
